<?php if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=""){?>
<div class="col-md-8">
<div class="main-content" id="main-content">
	<div class="sub-content">
		<div class="top-header page-header clearfix">
			<h1>User Profile</h1>
		</div>
		
		<div class="top-links">
			<ul class="form-progress-bar">
				<? if(isset($_GET['edit']) && $_GET['edit']!=""){?>
					<li class="active-menu step-no"><a href="<? echo $this->Url('users')?>/user-previous?user_id=<? echo $_GET['user_id'];?>&edit=1"><span>1</span></a></li>
					<li class="indicator active-menu"><span></span></li>
					<li class="active-menu step-no"><a  href="<? echo $this->Url('users')?>/super-user-next?user_id=<? echo $_GET['user_id'];?>&edit=1"><span>2</span></a></li>
					<li class="indicator"><span></span></li>
				<?}else if(isset($_GET['user_id']) && $_GET['user_id']!=""){?>
					<li class="active-menu step-no"><a href="<? echo $this->Url('users')?>/user-previous?user_id=<? echo $_GET['user_id'];?>"><span>1</span></a></li>
					<li class="indicator active-menu"><span></span></li>
					<li class="active-menu step-no"><a  href="<? echo $this->Url('users')?>/super-user-next?user_id=<? echo $_GET['user_id'];?>"><span>2</span></a></li>
					<li class="indicator"><span></span></li>
				<?}else{?>
					<li class="active-menu step-no"><a href="<? echo $this->Url('users')?>/user-previous"><span>1</span></a></li>
					<li class="indicator active-menu"><span></span></li>
					<li class="active-menu step-no"><a  href="<? echo $this->Url('users')?>/super-user-next"><span>2</span></a></li>
					<li class="indicator"><span></span></li>
				<?}?>
				<li class="step-no"><span>3</span></li>
			</ul>
		</div>
		<div class="middle-forms user-profile1 col-md-11">
			<form id="formid" method="post" class="form-horizontal" role="form">
				<div class="sub-forms">
					<div class="form-group">
						<label class="control-label col-sm-3">Contact Person 1</label>
						 <div class="col-sm-9">
						 <? if(isset($_SESSION['usersinfo']['cperson'])){?>
							<input  type="text" id="cperson" name="cperson" class="form-control"  value="<? echo $_SESSION['usersinfo']['cperson'];?>" placeholder="Contact Person 1"> 
						<?} else if(isset($this->user_details->contact_person)){?>
						<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
							<input  type="text" id="cperson" class="form-control" value="<? if(isset($this->user_details->contact_person)){echo $this->user_details->contact_person;}?>" name="cperson" placeholder="Contact Person 1">
                        <?}else{?>
						  <input  type="text" id="cperson" class="form-control" readonly="readonly" value="<? if(isset($this->user_details->contact_person)){echo $this->user_details->contact_person;}?>" name="cperson" placeholder="Contact Person 1">
						<?}}else{?>	
							<input  type="text" id="cperson" name="cperson" class="form-control" placeholder="Contact Person 1">
						 <?}?></div>				 
					</div><span style="color:red" id="errorcperson"></span>
					<div class="form-group">
						<label class="control-label col-sm-3">Mobile No</label>
						<div class="col-sm-9">
						<? if(isset($_SESSION['usersinfo']['mobile'])){?>
							<input  type="text" id="mobile" name="mobile"  class="form-control" value="<? echo $_SESSION['usersinfo']['mobile'];?>" placeholder="Mobile No"> 
						<?} else if(isset($this->user_details->mobile)){?>
						 <? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
						<input  type="text" id="mobile" class="form-control" value="<? if(isset($this->user_details->mobile)){echo $this->user_details->mobile;}?>" name="mobile" placeholder="mobile No" />
					    <?}else{?>	
						<input  type="text" id="mobile" class="form-control" readonly="readonly" value="<? if(isset($this->user_details->mobile)){echo $this->user_details->mobile;}?>" name="mobile" placeholder="mobile No" />
						<?}}else{?>	
						 <input  type="text" id="mobile" name="mobile" class="form-control" placeholder="mobile No">
						 <?}?></div>
					</div><span style="color:red" id="errormobile"></span>
					<div class="form-group">
						<label class="control-label col-sm-3">Email Address</label>
						<div class="col-sm-9">
						<? if(isset($_SESSION['usersinfo']['second_email'])){?>
							<input  type="text" id="email" name="email"  class="form-control" value="<? echo $_SESSION['usersinfo']['second_email'];?>" placeholder="Email"> 
						<?}else if(isset($this->user_details->second_email)){?>
						<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
							<input  type="text" id="email" name="email" class="form-control" value="<? if(isset($this->user_details->second_email)){echo $this->user_details->second_email;}?>" placeholder="Email" />
						<?}else{?>
							<input  type="text" id="email" name="email" class="form-control"  readonly="readonly" value="<? if(isset($this->user_details->second_email)){echo $this->user_details->second_email;}?>" placeholder="Email" />
						<?}}else{?>	
							<input  type="text" id="email" name="email" class="form-control" placeholder="Email">
						 <?}?></div>
					</div></span><span style="color:red" id="erroremail"></span>
				    <div class="form-group">
						<label class="control-label col-sm-3">Bank Address</label>
						<div class="col-sm-9">
						<? if(isset($_SESSION['usersinfo']['baddress'])){?>
							<textarea  class="profile_add"  id="baddress" name="baddress" class="form-control" placeholder="Bank Address" ><? echo $_SESSION['usersinfo']['baddress'];?></textarea>
						<?}else if(isset($this->user_details->bankaddress)){?>
						<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
							<textarea  class="profile_add"  id="baddress" name="baddress" class="form-control" placeholder="Bank Address" ><? if(isset($this->user_details->bankaddress)){echo $this->user_details->bankaddress;}?></textarea>
						<?}else{?>	
							<textarea  class="profile_add"  id="baddress" name="baddress" class="form-control" readonly="readonly" placeholder="Bank Address" ><? if(isset($this->user_details->bankaddress)){echo $this->user_details->bankaddress;}?></textarea>
						<?}}else{?>	
							<textarea  class="profile_add"  id="baddress" name="baddress" class="form-control" placeholder="Bank Address" ></textarea>
						 <?}?></div>
					</div><span style="color:red" id="errorbaddress"></span>
					<div class="form-group">
						<label class="control-label col-sm-3">Account No</label>
						<div class="col-sm-9">
						<? if(isset($_SESSION['usersinfo']['acno'])){?>
							<textarea  class="profile_add form-control"  id="acno" name="acno" placeholder="Account No" ><? echo $_SESSION['usersinfo']['acno'];?></textarea>
						<?} else if(isset($this->user_details->account_number)){?>
						<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
							<textarea  class="profile_add form-control"  id="acno" name="acno" placeholder="Account No" ><? echo $this->user_details->account_number;?></textarea>
						<?}else{?>	
						   <input  type="text" id="acno" name="acno"  class="form-control" readonly="readonly" value="<? if(isset($this->user_details->account_number)){echo $this->user_details->account_number;}?>" placeholder="Account No" />
						<?}}else{?>	
						 <textarea  class="profile_add"  id="acno" name="acno" class="form-control" placeholder="Account No" ></textarea>
						 <?}?></div>
					</div><span style="color:red" id="erroracno"></span>
					<div class="form-group">
						<label class="control-label col-sm-3">Note</label>
						<div class="col-sm-9">
						<? if(isset($_SESSION['usersinfo']['note'])){?>
							<textarea  class="profile_add form-control"  id="note" name="note" placeholder="Note" ><? echo $_SESSION['usersinfo']['note'];?></textarea>
						<?} else if(isset($this->user_details->note)){?>
						<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
							<textarea  class="profile_add form-control"  id="note" name="note" placeholder="Note" ><? if(isset($this->user_details->note)){echo $this->user_details->note;}?></textarea>
						<?}else{?>	
							<textarea  class="profile_add form-control"  id="note" name="note"  readonly="readonly" placeholder="Note" ><? if(isset($this->user_details->note)){echo $this->user_details->note;}?></textarea>
						<?}}else{?>	
							<textarea  class="profile_add form-control"  id="note" name="note" placeholder="Note" ></textarea>
						 <?}?></div>
					</div><span style="color:red" id="errornote"></span>
					<div class="form-group">
						<label class="control-label col-sm-3">User Type</label>
							<div class="col-sm-9">
							<? if(isset($_SESSION['usersinfo']['type'])){ ?>						
								<input  type="text" id="type1" name="type1" class="form-control" readonly="readonly" value="Superadmin" placeholder="Type of user">
								<input  type="hidden" id="type" name="type"   value="superadmin"> 
							<? } else if(isset($this->user_details->user_type) && $this->user_details->user_type=='superadmin'){?>
								<input  type="text" id="type1" name="type1" class="form-control" readonly="readonly" value="Superadmin" placeholder="Type of user">
								<input  type="hidden" id="type" name="type"   value="superadmin"> 
							<?}else{?>
								<input  type="text" id="type1" name="type1" class="form-control" readonly="readonly" value="Superadmin" placeholder="Type of user">
								<input  type="hidden" id="type" name="type"   value="superadmin"> 
							<?}?></div>
					</div>
					<span style="color:red" id="errortype"></span>
					<div class="form-group">
						<? if(isset($_GET['edit']) && $_GET['edit']!=""){?>					
							<div class="form-group">
								<label class="control-label col-sm-3">Select the status</label>
								
								<div class="col-sm-9 select_6">
									<select id="status" name="status" class="form-control">
										<option value="">-Select a status-</option>	
										<? if(isset($this->user_details->u_status)){if($this->user_details->u_status==1){?>
											<option value="1" selected="selected">Activate</option>	
											<option value="0">Pending</option>
											<option value="2">Deactivate</option>
										<?}else if($this->user_details->u_status==2){?>
											<option value="1">Activate</option>	
											<option value="0">Pending</option>
											<option value="2" selected="selected">Deactivate</option>
										<?} else if($this->user_details->u_status==0){?>
											<option value="1">Activate</option>	
											<option value="0" selected="selected">Pending</option>
											<option value="2">Deactivate</option>
										<?}}?>										
									</select>
								</div>
							</div>
						<? }else if(isset($this->user_details->user_type)){ 
						 if($this->user_details->user_type=='admin'){?>
							 <? if(isset($this->user_details->u_status) && $this->user_details->u_status=1){?>
								<label class="control-label col-sm-3">Your Status</label>
								<input  type="text" readonly="readonly" value="Accepted" class="form-control"/>
								<input  type="hidden" readonly="readonly" id="status" value="<? echo $this->user_details->u_status;?>" name="status"/>
							<?}?>
						<?}else if($this->user_details->user_type=='user'){?>
							<? if(isset($this->user_details->u_status) && $this->user_details->u_status=1){?>
								<label class="control-label col-sm-3">Your Status</label>
								<input  type="text" readonly="readonly" value="Accepted" class="form-control"/>
								<input  type="hidden" readonly="readonly" id="status" value="<? echo $this->user_details->u_status;?>" name="status"/>
							<?}?>
						<?}else if($this->user_details->user_type=='superadmin'){?>
							<? if(isset($this->user_details->u_status) && $this->user_details->u_status=1){?>
								<input  type="hidden" readonly="readonly" id="status" value="<? echo $this->user_details->u_status;?>" name="status"/>
							<?}?>
						<?}}?>
					</div>
					<input type="hidden" id="hid_user_id" name="hid_user_id" value="<? if(isset($this->user_details->user_id)){echo $this->user_details->user_id;}?>"/>					
					<input type="hidden" id="edit_status" name="edit_status" value="<? if(isset($_GET['edit'])){echo $_GET['edit'];}?>">
					<div class="form-group">
					<label class="col-sm-3">&nbsp;</label>
						<a href="javascript:void(0)"  id="register" onclick="return registrationsucc();" role="button" class="btn btn-danger">Continue</a>
					</div>
				</div>
			</form>
		</div>
	</div>
</div></div>
<script type="text/javascript">
function registrationsucc(){
        var flag=true;	
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var letters = /^[a-zA-Z ]*$/; 
		var numbers = /^[+-]?\d+$/;
		var cperson=$('#cperson').val();
		var mnumber=$('#mobile').val();
		var email=$('#email').val();  
		var cperson1=$('#cperson1').val();
		var mnumber1=$('#mobile1').val();
		var email1=$('#email1').val(); 
		var bankaddress=$('#baddress').val();
		var acnumber=$('#acno').val();
		var note=$('#note').val(); 
		var type=$('#type').val();
		
		if(cperson==""){
			$('#errorcperson').html('*Contact person is required');	
			flag=false;
		}else if(!cperson.match(letters)){
			$('#errorcperson').html('');
			$("#errorcperson").html("*Characters only");
			flag=false;
		}else{
			$('#errorcperson').html('');
		}
		if(mnumber==""){
		  $('#errormobile').html('*Mobile number is required');
		  flag=false;
		}else if(isNaN(mnumber)){
			$('#errormobile').html('Invalid phone number ');
			flag=false;
		}else{
			$('#errormobile').html('');
		}
		if(email==""){
		  $('#erroremail').html('*Second user email');
		  flag=false;
		}else if(!filter.test(email)){
		  $('#erroremail').html('Email format is not correct');
		   flag=false;
		}else{
		   $('#erroremail').html('');
		}
		if(bankaddress==""){
			$('#errorbaddress').html('*Bank address is required');	
			flag=false;
		}else{
			$('#errorbaddress').html('');
		}
		if(acnumber==""){
			$('#erroracno').html('*Account number is required');	
			flag=false;
		}else{
			$('#erroracno').html('');
		}
		if(note==""){
			$('#errornote').html('*Note is required');	
			flag=false;
		}else{
			$('#errornote').html('');
		}
		if(type==""){
			$('#errortype').html('*Please enter type');
			flag=false;
		}else{
			$('#errortype').html('');
		}
		if(flag==false){ 
			return false;
		}else{		
			$("#formid").submit();
		}
}
</script>
<?php }else{?>
<script>
	window.location='<? echo $this->Url('home')?>';
</script>
<?php }?>       
